<template>
    <div class="main_box" style="padding:10px">
        <div class="add_wrap">
            <el-form label-width="200px">
                <div class="tit">
                    <h2>基础信息</h2>
                    <el-button type="success" plain size="small" icon="fa fa-mail-forward" @click="returnList">返回
                    </el-button>
                </div>
                <el-row>
                    <el-form-item label="用户昵称:">
                        <span>{{ dataInfo.userName }}</span>
                    </el-form-item>
                    <el-form-item label="商户名称:">
                        <span>{{ dataInfo.businessName }}</span>
                    </el-form-item>
                    <el-form-item label="提现金额(元):">
                        <span>{{ dataInfo.amount }}</span>
                    </el-form-item>
                    <el-form-item label="提现编号:">
                        <span>{{ dataInfo.cashNo }}</span>
                    </el-form-item>
                    <el-form-item label="提现状态:">
                        <span>{{ formatCashState(dataInfo.cashState) }}</span>
                    </el-form-item>
                    <el-form-item label="内容:">
                        <span>{{ dataInfo.content }}</span>
                    </el-form-item>
                    <el-form-item label="用户备注:">
                        <span>{{ dataInfo.remark }}</span>
                    </el-form-item>
                    <el-form-item label="内部备注:">
                        <span>{{ dataInfo.insideRemark }}</span>
                    </el-form-item>
                    <el-form-item label="打款人:">
                        <span>{{ dataInfo.paymentUserName }}</span>
                    </el-form-item>
                    <el-form-item label="打款时间:">
                        <span>{{ dataInfo.paymentDate }}</span>
                    </el-form-item>
                    <el-form-item label="完成时间:">
                        <span>{{ dataInfo.completeDate }}</span>
                    </el-form-item>

                    <el-form-item label="完成备注:">
                        <span>{{ dataInfo.completeRemark }}</span>
                    </el-form-item>

                    <el-form-item label="创建人:">
                        <span>{{ dataInfo.createUserName }}</span>
                    </el-form-item>
                    <el-form-item label="创建时间:">
                        <span>{{ dataInfo.createDate }}</span>
                    </el-form-item>
                    <el-form-item label="修改人:">
                        <span>{{ dataInfo.modifyUserName }}</span>
                    </el-form-item>
                    <el-form-item label="修改时间:">
                        <span>{{ dataInfo.modifyDate }}</span>
                    </el-form-item>
                </el-row>
                <div class="tit">
                    <h2>
                        账户信息
                    </h2>
                </div>
                <el-row>

                    <el-form-item label="账户类型:">
                        <span>{{ accountInfo.cardType===1?'对公账户':'个人账户' }}</span>
                    </el-form-item>
                    <el-form-item label="用户类型:">
                        <span>{{ formatUserType(accountInfo.userType) }}</span>
                    </el-form-item>
                    <el-form-item label="姓名:">
                        <span>{{ accountInfo.fullName }}</span>
                    </el-form-item>
                    <el-form-item label="手机号:">
                        <span>{{ accountInfo.phone }}</span>
                    </el-form-item>
                    <el-form-item label="身份证:">
                        <span>{{ accountInfo.idCard}}</span>
                    </el-form-item>
                    <el-form-item label="企业名称:" v-if="accountInfo.businessName">
                        <span>{{ accountInfo.businessName }}</span>
                    </el-form-item>
                    <el-form-item label="企业联系人:" v-if="accountInfo.linkName">
                        <span>{{ accountInfo.linkName }}</span>
                    </el-form-item>
                    <el-form-item label="企业联系电话:" v-if="accountInfo.linkPhone">
                        <span>{{ accountInfo.linkPhone }}</span>
                    </el-form-item>
                    <el-form-item label="银行:">
                        <span>{{ accountInfo.bankName}}</span>
                    </el-form-item>
                    <el-form-item label="银行编号:">
                        <span>{{ accountInfo.branchCode}}</span>
                    </el-form-item>
                    <el-form-item label="银行支行:">
                        <span>{{ accountInfo.branchName}}</span>
                    </el-form-item>
                    <el-form-item label="支行编号:">
                        <span>{{ accountInfo.branchCode}}</span>
                    </el-form-item>
                    <el-form-item label="银行卡号:">
                        <span>{{ accountInfo.bankCode}}</span>
                    </el-form-item>

                </el-row>
                <div class="tit" v-if="dataInfo.cashState===1">
                    <h2>操作</h2>
                </div>
                <el-row v-if="dataInfo.cashState===1">
                    <div class="inside-remark">
                        <div class="label">
                            内部备注:
                        </div>
                        <el-input type="textarea" rows="5" v-model="remark">

                        </el-input>
                    </div>
                    <div class="btn">
                        <el-button type="success" @click="transferFunds">
                        已转款
                    </el-button>
                    <el-button @click="returnList">
                        取消
                    </el-button>
                    </div>

                </el-row>
            </el-form>

        </div>
    </div>
</template>

<script>
import CashRecordApi from '@/api/finance/cashRecord';
import YmAccountApi from '@/api/account/ymAccount';
export default {
    data() {
        return {
            dataInfo: {},
            list: [],
            cashRecordId:"",
            remark:"",
            accountInfo:{},
        };
    },
    computed: {
    },
    mounted() {
        this.getData()
    },
    methods: {
        getData() {
            this.cashRecordId = this.$route.query.id
            CashRecordApi.getCashRecordInfo({ id: this.cashRecordId }).then(res => {
                this.dataInfo = res.data
                this.getAccountInfo()
            })

        },
        async getAccountInfo(){
            const {merchantId} = this.dataInfo
            if(!merchantId) return
            const res = await YmAccountApi.getDataById({merchantId})
            this.accountInfo = res.data
        },
        formatCashState(cellValue) {
            if (cellValue === 1) {
                return '提现中'
            } else if (cellValue === 5) {
                return '已提现'
            } else if (cellValue === 10) {
                return '用户告知未到账'
            } else if (cellValue === 15) {
                return "提现失败"
            } else if (cellValue === 20) {
                return "提现成功"
            }
        },
        formatUserType(cellValue) {
            if (cellValue === 1) {
                return '企业商户'
            } else if (cellValue === 2) {
                return '个体工商户'
            } else if (cellValue === 3) {
                return '个人'
            }
        },
        transferFunds(){
            this.$confirm("确认已转账？",'提示',{}).then(()=>{
                const {cashRecordId,remark} = this
                const params = {
                    id:cashRecordId,
                    state:5,
                    content:remark,
                }
                CashRecordApi.recordOperation(params).then(()=>{
                    this.$Utils.notifySuccess()
                    this.returnList()
                })
            })
        },
        returnList() {
            this.$store.dispatch('delView', this.$route);
            this.$router.push({ path: '/finance/cashRecordManagement' })
        }
    },

}

</script>
<style lang="scss" scoped>
@import "@/assets/css/views/add.scss";
</style>
<style lang="scss" scoped>
.account {
    display: flex;
    justify-content: space-between;

    .el-card {
        width: 46%;

        ::v-deep .el-card__header {
            font-size: 14px;
        }

        .item {
            display: flex;
            align-items: center;
            line-height: 30px;
            font-size: 14px;

            .label {
                width: 100px;
            }

            .value {
                width: 150px;
            }
        }
    }

}
.inside-remark{
    display: flex;
    margin-bottom: 20px;
    .el-textarea{
        width: 300px;
    }
    .label{
        font-size: 14px;
        width: 190px;
        padding-right: 10px;
        text-align: end;

    }
}
.btn{
    text-align: center;
}
</style>
